Kinetis SDK API Reference Manual  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages

The section describes the programming interface of the PORT HAL driver. More...

Enumerations

enum  port_pull_t {
  kPortPullDown = 0U,
  kPortPullUp = 1U
}
 Internal resistor pull feature selection. More...
 
enum  port_slew_rate_t {
  kPortFastSlewRate = 0U,
  kPortSlowSlewRate = 1U
}
 Slew rate selection. More...
 
enum  port_drive_strength_t {
  kPortLowDriveStrength = 0U,
  kPortHighDriveStrength = 1U
}
 Configures the drive strength. More...
 
enum  port_mux_t {
  kPortPinDisabled = 0U,
  kPortMuxAsGpio = 1U,
  kPortMuxAlt2 = 2U,
  kPortMuxAlt3 = 3U,
  kPortMuxAlt4 = 4U,
  kPortMuxAlt5 = 5U,
  kPortMuxAlt6 = 6U,
  kPortMuxAlt7 = 7U
}
 Pin mux selection. More...
 
enum  port_interrupt_config_t {
  kPortIntDisabled = 0x0U,
  kPortDmaRisingEdge = 0x1U,
  kPortDmaFallingEdge = 0x2U,
  kPortDmaEitherEdge = 0x3U,
  kPortIntLogicZero = 0x8U,
  kPortIntRisingEdge = 0x9U,
  kPortIntFallingEdge = 0xAU,
  kPortIntEitherEdge = 0xBU,
  kPortIntLogicOne = 0xCU
}
 Digital filter clock source selection. More...
 

Configuration

static void port_hal_pull_select (uint32_t instance, uint32_t pin, port_pull_t pullSelect)
 Selects the internal resistor as pull-down or pull-up. More...
 
static void port_hal_configure_pull (uint32_t instance, uint32_t pin, bool isPullEnabled)
 Enables or disables the internal pull resistor. More...
 
static void port_hal_configure_slew_rate (uint32_t instance, uint32_t pin, port_slew_rate_t rateSelect)
 Configures the fast/slow slew rate if the pin is used as a digital output. More...
 
static void port_hal_configure_passive_filter (uint32_t instance, uint32_t pin, bool isPassiveFilterEnabled)
 Configures the passive filter if the pin is used as a digital input. More...
 
static void port_hal_configure_drive_strength (uint32_t instance, uint32_t pin, port_drive_strength_t driveSelect)
 Configures the drive strength if the pin is used as a digital output. More...
 
static void port_hal_mux_control (uint32_t instance, uint32_t pin, port_mux_t mux)
 Configures the pin muxing. More...
 
void port_hal_global_pin_control_low (uint32_t instance, uint16_t lowPinSelect, uint16_t config)
 Configures the low half of pin control register for the same settings. More...
 
void port_hal_global_pin_control_high (uint32_t instance, uint16_t highPinSelect, uint16_t config)
 Configures the high half of pin control register for the same settings. More...
 

Interrupt

static void port_hal_configure_pin_interrupt (uint32_t instance, uint32_t pin, port_interrupt_config_t intConfig)
 Configures the port pin interrupt/DMA request. More...
 
static port_interrupt_config_t port_hal_get_pin_interrupt_config (uint32_t instance, uint32_t pin)
 Gets the current port pin interrupt/DMA request configuration. More...
 
static bool port_hal_read_pin_interrupt_flag (uint32_t instance, uint32_t pin)
 Reads the individual pin-interrupt status flag. More...
 
static void port_hal_clear_pin_interrupt_flag (uint32_t instance, uint32_t pin)
 Clears the individual pin-interrupt status flag. More...
 
static uint32_t port_hal_read_port_interrupt_flag (uint32_t instance)
 Reads the entire port interrupt status flag. More...
 
static void port_hal_clear_port_interrupt_flag (uint32_t instance)
 Clears the entire port interrupt status flag. More...
 

PORT HAL Driver

Overview

Port control and interrupts hardware driver configuration. Use these functions to set port control and external interrupt functions. Most functions can be configured independently for each pin in the 32-bit port and affect the pin regardless of its pin muxing state. To use these functions, pass into instance number (HW_PORTA, HW_PORTB, HW_PORTC, etc).

Enumeration Type Documentation

Enumerator
kPortPullDown 

internal pull-down resistor is enabled.

kPortPullUp 

internal pull-up resistor is enabled.

Enumerator
kPortFastSlewRate 

fast slew rate is configured.

kPortSlowSlewRate 

slow slew rate is configured.

Enumerator
kPortLowDriveStrength 

low drive strength is configured.

kPortHighDriveStrength 

high drive strength is configured.

enum port_mux_t
Enumerator
kPortPinDisabled 

corresponding pin is disabled as analog.

kPortMuxAsGpio 

corresponding pin is configured as GPIO.

kPortMuxAlt2 

chip-specific

kPortMuxAlt3 

chip-specific

kPortMuxAlt4 

chip-specific

kPortMuxAlt5 

chip-specific

kPortMuxAlt6 

chip-specific

kPortMuxAlt7 

chip-specific

Configures the interrupt generation condition.

Enumerator
kPortIntDisabled 

Interrupt/DMA request is disabled.

kPortDmaRisingEdge 

DMA request on rising edge.

kPortDmaFallingEdge 

DMA request on falling edge.

kPortDmaEitherEdge 

DMA request on either edge.

kPortIntLogicZero 

Interrupt when logic zero.

kPortIntRisingEdge 

Interrupt on rising edge.

kPortIntFallingEdge 

Interrupt on falling edge.

kPortIntEitherEdge 

Interrupt on either edge.

kPortIntLogicOne 

Interrupt when logic one.

Function Documentation

static void port_hal_pull_select ( uint32_t  instance,
uint32_t  pin,
port_pull_t  pullSelect 
)
inlinestatic

Pull configuration is valid in all digital pin muxing modes.

Parameters
instanceport instance number.
pinport pin number
pullSelectinternal resistor pull feature selection
  • kPortPullDown: internal pull-down resistor is enabled.
  • kPortPullUp : internal pull-up resistor is enabled.
static void port_hal_configure_pull ( uint32_t  instance,
uint32_t  pin,
bool  isPullEnabled 
)
inlinestatic
Parameters
instanceport instance number
pinport pin number
isPullEnabledinternal pull resistor enable or disable
  • true : internal pull resistor is enabled.
  • false: internal pull resistor is disabled.
static void port_hal_configure_slew_rate ( uint32_t  instance,
uint32_t  pin,
port_slew_rate_t  rateSelect 
)
inlinestatic
Parameters
instanceport instance number
pinport pin number
rateSelectslew rate selection
  • kPortFastSlewRate: fast slew rate is configured.
  • kPortSlowSlewRate: slow slew rate is configured.
static void port_hal_configure_passive_filter ( uint32_t  instance,
uint32_t  pin,
bool  isPassiveFilterEnabled 
)
inlinestatic

If enabled, a low pass filter (10 MHz to 30 MHz bandwidth) is enabled on the digital input path. Disable the Passive Input Filter when supporting high speed interfaces (> 2 MHz) on the pin.

Parameters
instanceport instance number
pinport pin number
isPassiveFilterEnabledpassive filter configuration
  • false: passive filter is disabled.
  • true : passive filter is enabled.
static void port_hal_configure_drive_strength ( uint32_t  instance,
uint32_t  pin,
port_drive_strength_t  driveSelect 
)
inlinestatic
Parameters
instanceport instance number
pinport pin number
driveSelectdrive strength selection
  • kLowDriveStrength : low drive strength is configured.
  • kHighDriveStrength: high drive strength is configured.
static void port_hal_mux_control ( uint32_t  instance,
uint32_t  pin,
port_mux_t  mux 
)
inlinestatic
Parameters
instanceport instance number
pinport pin number
muxpin muxing slot selection
  • kPinDisabled: Pin disabled.
  • kMuxAsGpio : Set as GPIO.
  • others : chip-specific.
void port_hal_global_pin_control_low ( uint32_t  instance,
uint16_t  lowPinSelect,
uint16_t  config 
)
   This function operates pin 0 -15 of one specific port.
Parameters
instanceport instance number
pinSelectupdate corresponding pin control register or not. For a specific bit:
  • 0: corresponding low half of pin control register won't be updated according to configuration.
  • 1: corresponding low half of pin control register will be updated according to configuration.
configvalue is written to a low half port control register bits[15:0].
void port_hal_global_pin_control_high ( uint32_t  instance,
uint16_t  highPinSelect,
uint16_t  config 
)
   This function operates pin 16 -31 of one specific port.
Parameters
instanceport instance number
pinSelectupdate corresponding pin control register or not. For a specific bit:
  • 0: corresponding high half of pin control register won't be updated according to configuration.
  • 1: corresponding high half of pin control register will be updated according to configuration.
configvalue is written to a high half port control register bits[15:0].
static void port_hal_configure_pin_interrupt ( uint32_t  instance,
uint32_t  pin,
port_interrupt_config_t  intConfig 
)
inlinestatic
Parameters
instanceport instance number.
pinport pin number
intConfiginterrupt configuration
  • kIntDisabled : Interrupt/DMA request disabled.
  • kDmaRisingEdge : DMA request on rising edge.
  • kDmaFallingEdge: DMA request on falling edge.
  • kDmaEitherEdge : DMA request on either edge.
  • KIntLogicZero : Interrupt when logic zero.
  • KIntRisingEdge : Interrupt on rising edge.
  • KIntFallingEdge: Interrupt on falling edge.
  • KIntEitherEdge : Interrupt on either edge.
  • KIntLogicOne : Interrupt when logic one.
static port_interrupt_config_t port_hal_get_pin_interrupt_config ( uint32_t  instance,
uint32_t  pin 
)
inlinestatic
Parameters
instanceport instance number
pinport pin number
Returns
interrupt configuration
  • kIntDisabled : Interrupt/DMA request disabled.
  • kDmaRisingEdge : DMA request on rising edge.
  • kDmaFallingEdge: DMA request on falling edge.
  • kDmaEitherEdge : DMA request on either edge.
  • KIntLogicZero : Interrupt when logic zero.
  • KIntRisingEdge : Interrupt on rising edge.
  • KIntFallingEdge: Interrupt on falling edge.
  • KIntEitherEdge : Interrupt on either edge.
  • KIntLogicOne : Interrupt when logic one.
static bool port_hal_read_pin_interrupt_flag ( uint32_t  instance,
uint32_t  pin 
)
inlinestatic

If a pin is configured to generate the DMA request, the corresponding flag is cleared automatically at the completion of the requested DMA transfer. Otherwise, the flag remains set until a logic one is written to that flag. If configured for a level sensitive interrupt that remains asserted, the flag is set again immediately.

Parameters
instanceport instance number
pinport pin number
Returns
current pin interrupt status flag
  • 0: interrupt is not detected.
  • 1: interrupt is detected.
static void port_hal_clear_pin_interrupt_flag ( uint32_t  instance,
uint32_t  pin 
)
inlinestatic
Parameters
instanceport instance number
pinport pin number
static uint32_t port_hal_read_port_interrupt_flag ( uint32_t  instance)
inlinestatic
Parameters
instanceport instance number
Returns
all 32 pin interrupt status flags. For specific bit:
  • 0: interrupt is not detected.
  • 1: interrupt is detected.
static void port_hal_clear_port_interrupt_flag ( uint32_t  instance)
inlinestatic
Parameters
instanceport instance number